﻿CREATE TABLE [PR].[PriceLinesParsed] (
    [Id]                   INT             IDENTITY (1, 1) NOT NULL,
    [GoodsVsContragentsId] INT             NOT NULL,
    [ContragentId]         INT             NOT NULL,
    [GoodsId]              INT             NOT NULL,
    [Price]                DECIMAL (19, 2) NOT NULL,
    [Qntty]                INT             NOT NULL,
    [NDSTax]               TINYINT         NULL,
    [BatchNumber]          VARCHAR (20)    NULL,
    [ReadyBefore]          SMALLDATETIME   NULL,
    [ReestrPrice]          DECIMAL (19, 2) NULL,
    [ReestrDate]           SMALLDATETIME   NULL,
    [Note]                 VARCHAR (250)   NULL,
    CONSTRAINT [PK_PriceLinesParsed] PRIMARY KEY NONCLUSTERED ([Id] ASC),
    CONSTRAINT [FK_PriceLinesParsed_Contragents] FOREIGN KEY ([ContragentId]) REFERENCES [CA].[Contragents] ([Id]) ON DELETE CASCADE NOT FOR REPLICATION,
    CONSTRAINT [FK_PriceLinesParsed_Goods] FOREIGN KEY ([GoodsId]) REFERENCES [CA].[Goods] ([Id]) NOT FOR REPLICATION,
    CONSTRAINT [FK_PriceLinesParsed_GoodsVsContragents] FOREIGN KEY ([GoodsVsContragentsId]) REFERENCES [CA].[GoodsVsContragents] ([Id]) NOT FOR REPLICATION
);


GO
CREATE NONCLUSTERED INDEX [IX_PriceLinesParsed_GoodsVsContragentsId]
    ON [PR].[PriceLinesParsed]([GoodsVsContragentsId] ASC);


GO
CREATE NONCLUSTERED INDEX [IX_PriceLinesParsed_ContragentId]
    ON [PR].[PriceLinesParsed]([ContragentId] ASC);


GO
CREATE NONCLUSTERED INDEX [IX_PriceLinesParsed_GoodsId]
    ON [PR].[PriceLinesParsed]([GoodsId] ASC);


GO
CREATE NONCLUSTERED INDEX [IX_PriceLinesParsed_Price]
    ON [PR].[PriceLinesParsed]([Price] ASC);


GO
EXECUTE sp_addextendedproperty @name = N'MS_Description', @value = N'Значение ставки НДС', @level0type = N'SCHEMA', @level0name = N'PR', @level1type = N'TABLE', @level1name = N'PriceLinesParsed', @level2type = N'COLUMN', @level2name = N'NDSTax';


GO
EXECUTE sp_addextendedproperty @name = N'MS_Description', @value = N'Серия', @level0type = N'SCHEMA', @level0name = N'PR', @level1type = N'TABLE', @level1name = N'PriceLinesParsed', @level2type = N'COLUMN', @level2name = N'BatchNumber';

